package com.ruxiaoxin.share.domain.user;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author ruxiaoxin
 */
public class Role implements Serializable {
	private static final long serialVersionUID = 1L;
	private String id; // 角色id
	private String roleName; // 角色名
	private String alias; // 别名
	private List<Permission> permissiones = new ArrayList<Permission>(); // 角色所拥有的权限

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getAlias() {
		return alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}

	public List<Permission> getPermissiones() {
		if (permissiones == null) {
			return new ArrayList<Permission>();
		}
		return permissiones;
	}

	public void setPermissiones(List<Permission> permissiones) {
		this.permissiones = permissiones;
	}

	public boolean hasPermissiones() {
		return getPermissiones().isEmpty() ? false : true;
	}
	/**
	 * 重写该类equals方法，如id相同则两个对象相同
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Role other = (Role) obj;
		if (this.getId() == null || other.getId() == null) {
			return false;
		}
		if (!this.getId().equals(other.getId())) {
			return false;
		}
		return true;
	}
}
